<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/ajax.js"></script>
</head>

<body>

</body>
<script>
    // ajax({
    //     type: "get",
    //     url: "../data/2.txt",
    //     async: true,
    //     dataType: "json",
    //     success: function (res) {
    //         console.log("请求成功", res);
    //     },
    //     // error: function (err) {
    //     //     console.log("发生错误", err.message);
    //     // }
    // })


    console.log("代码开始");

    setTimeout(function fn1() {
        console.log("延时器执行");
    }, 1000)


    var xhr = new XMLHttpRequest();

    xhr.open("get", "../data/1.txt", true);

    xhr.send();

    xhr.onreadystatechange = function fn2() {
        if (xhr.readyState == 4 && xhr.status == 200) {
            var result = xhr.responseText;

        }
    }


    document.onclick = function fn3() {
        console.log("文档被点击");
    }

    console.log("代码结束");



</script>

</html>